<template>
  <el-table :data="tableData" style="width: 100%" height="725px">
    <el-table-column prop="id" label="项目编号" width="180"></el-table-column>
    <el-table-column prop="price" label="报价" width="180"></el-table-column>
    <el-table-column prop="lable" label="项目需求"></el-table-column>

    <el-table-column label="竞标状态"
      ><template slot-scope="scope"
        ><el-tag type="warning" v-if="scope.row.status === '竞标中'">{{
          scope.row.status
        }}</el-tag>
        <el-tag type="danger" v-if="scope.row.status === '竞标完成'">{{
          scope.row.status
        }}</el-tag></template
      ></el-table-column
    >
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini" @click="handleEdit(scope.row.id)"
          >查看详情</el-button
        >
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.row.id)"
          >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        {
          id: "",
          price: "",
          lable: "",
          status: "",
        },
      ],
    };
  },
  mounted: function () {
    let user = JSON.parse(window.sessionStorage.getItem("user"));
    axios
      .get("http://localhost:88/provider/user/checkBiddingByCompany", {
        params: { id: user.id },
      })
      .then((response) => {
        if (response.data != null) {
          let e = response.data;
          let data = [];
          for (let c = 0; c < e.length; c++) {
            let ee = e[c];
            let obj = {};
            obj.id = ee.id; //需求id
            obj.price = ee.money; //预算金额
            obj.lable = ee.lable; //需求标签
            obj.status = ee.status === 1 ? "竞标中" : "竞标完成"; //竞标状态
            data[c] = obj;
          }
          this.tableData = data;
        }
      });
  },
  methods: {
    //查看每组竞标，推荐打分
    handleEdit(demandId) {
      sessionStorage.setItem("demandId", demandId);
      this.$router.replace("/ProjectManageed");
    },

    //删除需求
    handleDelete(demandId){
      axios
        .post("http://localhost:88/provider/user/deleteDemand", {
          id: demandId,
        })
        .then((response) => {
          this.$message({
            message: "需求发布成功",
            type: "success",
          });
        });
      
    },

    jump(path) {
      this.$router.replace({ path: path });
    },

    jumpp(path) {
      // this.id= this.$route.query.mallCode
      this.$router.push({
        path: "/ApplyManage",
        query: {
          mallCode: path,
        },
      });
    },
  },
};
</script>



<style scoped>
</style>
